# -*- coding: iso-8859-15 -*-

#    SuperClipboard is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
import gtk

class WindowAbout(gtk.Window):
    
    def __init__(self,copier):
        gtk.Window.__init__(self,type=gtk.WINDOW_TOPLEVEL)
        self.copier = copier
        self.copier.gui.windows.append(self)
        self.set_title("SuperClipboard About")
        self.set_icon_from_file(self.copier.config.path['Ico'])
        self.set_resizable(False)
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        self.connect("delete-event",self.delete_event_callback)
        
        self.accel_group = gtk.AccelGroup()
        self.accel_group.connect_group(65307,0, gtk.ACCEL_VISIBLE, self.delete_by_accel_callback)
        self.add_accel_group(self.accel_group)
        
        self.build_window()
        
    def build_window(self): 
        main_vbox = gtk.VBox(False, 5)
        self.add(main_vbox)
        
        logo = gtk.Image()
        logo.set_from_file("./img/logo.png")
        main_vbox.pack_start(logo)
        main_vbox.pack_start(gtk.Label("Version  : "+self.copier.config.getstatic('Version')))
        main_vbox.pack_start(gtk.Label("Dev : PORTE Loïc"))
        main_vbox.pack_start(gtk.Label("Email : bewiwi@bibabox.fr"))
        main_vbox.pack_start(gtk.Label("Designer : BODJIKIAN Mathieu"))
        
        validate_cancel_button = gtk.Button('Cancel')
        validate_cancel_button.connect('clicked',self.destroy_callback)
        
        main_vbox.pack_start(validate_cancel_button)
        self.show_all()
    
    def delete_event_callback(self,*args):
        self.destroy_callback()
    
    def delete_by_accel_callback(self,accel_group,window,key,modifier):
        self.destroy_callback()
    
    def destroy_callback(self,element=None):
        self.copier.gui.windows.remove(self)
        self.destroy()
